<% if @sites.blank? %>

  <p class="error">There are no sites added yet.</p>

<% else %>

  <table>
    <thead>
      <tr>
        <th>Site</th>
        <th>Groups</th>
        <th>Runners</th>
        <th>Goal</th>
        <th>Miles</th>
        <th>Last Updated</th>
        <th class="last"></th>
        <th class="last"></th>
      </tr>
    </thead>
    <tbody>
      <% @sites.each do |site| %>
        <tr class="<%= cycle('odd', 'even') %>">
          <%if self.current_user.can('view:site', site) %>
            <td><%= link_to h(site.name), site %></td>
          <%else %>
            <td><%=site.name%></td>
          <%end%>
          <td><%= site.groups_cache %></td>
          <td><%= site.runners_cache %></td>
          <td><%= site.goal_cache %></td>
          <td><%= site.distance_cache %></td>
	  <td><%= time_ago_in_words site.updated_at %> ago</td>
          <td class="last">
          <%if self.current_user.can('edit:site', site) %>
            <%= link_to(image_tag('icons/pencil.png', :alt => 'Edit'), edit_site_path(site)) %>
          <%end%>
          <%if self.current_user.can('delete:site', site) %>
            <%= link_to(image_tag('icons/cross.png', :alt => 'Delete'), site, :confirm => 'Are you sure?', :method => :delete) %>
          <%end%>
          </td>
        <td class="last">
          <%= render(:partial => "shared/progress_small", :locals => { :distance => site.distance_cache, :goal => site.goal_cache }) %>
        </td>
          
        </tr>
      <% end %>
    </tbody>
  </table>

<% end %>
<%if self.current_user.can('edit:site', nil) %>
<p><%= link_to 'Add new site', new_site_path %></p>
<%end%>